import json

import cache
from dao.commonDao import FriendApply
from protoc import IMProto_pb2
from protoc.noticeType import NoticeType
from utils.transferUtil import TransferUtil


def process(head,msgBody):
    print(head)
    print(msgBody)
    notice = IMProto_pb2.Notice()
    notice.ParseFromString(msgBody)

    #判断notice类型
    extra = notice.extra
    extraObj = json.loads(extra)
    type = extraObj['type']
    if type == NoticeType.addFriend:
        cache.Cache.app.contactObject.receviedApply(notice)
    if type == NoticeType.examineFriend:
        cache.Cache.app.contactObject.examineApply(notice)
